﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using WMSADL.SY;
using WMSAML.SY;

namespace WMSABL.SY
{
    public class TGroupPermissionRelation_BLL
    {
        TGroupPermissionRelation_DAL dal = new TGroupPermissionRelation_DAL();
        public bool AddTGroupPermissionRelation(int gid, string roleStr)
        {
            bool falg = false;
            TGroupPermissionRelation_Entity entity = new TGroupPermissionRelation_Entity();
            entity.Group_id = gid;
            entity.Permission_id = roleStr;
            if (!ExistsByID(gid))
            {
                falg = Add(entity) == 0 ? false : true;
            }
            else
            {
                falg = Update(entity);
            }
            return falg;
        }

        /// <summary>
        /// 
        /// </summary>
        public int Add(TGroupPermissionRelation_Entity entity)
        {
            return dal.Add(entity);
        }

        /// <summary>
        /// ByGroupID
        /// </summary>
        public bool Delete(int gid)
        {
            return dal.Delete(gid);
        }

        /// <summary>
        /// ByID
        /// </summary>
        public bool ExistsByID(int gid)
        {
            return dal.ExistsByID(gid);
        }

        /// <summary>
        /// ByID
        /// </summary>
        /// <summary>
        public TGroupPermissionRelation_Entity GetEntityByID(int id)
        {
            return dal.GetEntityByID(id);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TGroupPermissionRelation_Entity entity)
        {
            return dal.Update(entity);
        }
    }
}
